package tk.mynoteapp.dev.demo05.ribbonretry;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("ribbonretryissueserver")
public class RibbonRetryIssueServerController {
    private Logger logger = LoggerFactory.getLogger(RibbonRetryIssueServerController.class);

    @GetMapping("sms")
    public void sendSmsWrong(@RequestParam("mobile") String mobile,
                              @RequestParam("message") String message,
                              HttpServletRequest request) throws InterruptedException {
        logger.info("{} is called, {}=>{}", request.getRequestURL().toString(), mobile, message);
        TimeUnit.SECONDS.sleep(2);
    }

    @PostMapping("sms")
    public void sendSmsRight(@RequestParam("mobile") String mobile,
                             @RequestParam("message") String message,
                             HttpServletRequest request) throws InterruptedException {
        logger.info("{} is called, {}=>{}", request.getRequestURL().toString(), mobile, message);
        TimeUnit.SECONDS.sleep(2);
    }
}
